package com.asset.pojo;

import com.asset.config.BigDecimalSerializer;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.Data;
import tk.mybatis.mapper.annotation.KeySql;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.Date;

/**
 * @author 11725
 * 资产信息
 */
@Data
@Table(name = "tab_asset")
public class Asset {
    /** 资产编号 */
    @Id
    @KeySql(useGeneratedKeys = true)
    @Column(name = "asset_id")
    private Long id;

    /** 分类编号 */
    private Long cid;

    /** 品牌编号 */
    private Long brandId;

    /** 部门编号 */
    private Long depaId;

    /** 仓库编号 */
    private Long depoId;

    /** 资产名称 */
    @NotBlank(message = "名称不得为空")
    @Column(name = "asset_name")
    private String name;

    /** 资产数量 */
    @NotNull(message = "数量不得为空")
    @Min(value = 1, message = "数量不得小于 1")
    @Column(name = "asset_number")
    private Integer number;

    /** 资产单价 */
    @NotNull(message = "单价不得为空")
    @DecimalMin(value = "0", message = "价格不得小于 0")
    @JsonSerialize(using = BigDecimalSerializer.class)
    @Column(name = "asset_price")
    private BigDecimal price;

    /** 预计净残值 */
    @JsonSerialize(using = BigDecimalSerializer.class)
    private BigDecimal netSalvage;

    /** 资产状态 */
    private Integer status;

    /** 入库日期 */
    @JsonFormat(pattern = "yyyy-MM-dd", timezone="GMT+8")
    private Date putDate;

    /** 折旧终止日期 */
    @JsonIgnore
    @Column(name = "depr_completed_date")
    private Date completedDate;

    /** 月折旧率 */
    @JsonSerialize(using = BigDecimalSerializer.class)
    private BigDecimal deprRate;

    /** 使用者编号 */
    private Long userId;

    /** 退还日期 */
    @JsonFormat(pattern = "yyyy-MM-dd", timezone="GMT+8")
    private Date dueDate;
}
